import 'package:flutter/material.dart';

class HiNestedScrollView extends StatelessWidget {
  final List<Widget> headers;
  final int itemCount;
  final IndexedWidgetBuilder itemBuilder;
  final SliverGridDelegate gridDelegate;
  final ScrollController? controller;
  final EdgeInsetsGeometry? padding;

  const HiNestedScrollView(
      {Key? key,
      this.headers = const [],
      required this.itemCount,
      required this.gridDelegate,
      required this.itemBuilder,
      this.controller,
      this.padding})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return ListView(
      controller: controller,
      padding: padding,
      children: [
        ...headers,
        GridView.builder(
            padding: EdgeInsets.all(0),
            //fix 不能一起滚动的问题
            physics: NeverScrollableScrollPhysics(),
            //fix嵌套滚动
            shrinkWrap: true,
            itemCount: itemCount,
            gridDelegate: gridDelegate,
            itemBuilder: itemBuilder)
      ],
    );
  }
}
